﻿using System;
namespace Benecura.Services.WebAPI.Proxy.Common
{
    public abstract class RestClientBase : RestSharp.RestClient
    {
        public RestProxy.ContentDataType ContentDataType { get; set; }
        /// <summary>
        /// Default constructor using JSON data exchange
        /// </summary>
        public RestClientBase()
        {
            SetContentDataType(RestProxy.ContentDataType.JSON);
        }

        /// <summary>
        /// Set context exchange data type
        /// </summary>
        /// <param name="dataType"></param>
        public void SetContentDataType(RestProxy.ContentDataType dataType)
        {
            ContentDataType = dataType;
            switch (dataType)
            {
                case RestProxy.ContentDataType.XML:
                    AddDefaultHeader("Accept", "application/xml");
                    break;
                default:
                    AddDefaultHeader("Accept", "application/json");
                    break;
            }
        }

        public abstract T Retrieve<T>(string command) where T : new();
        public abstract string Retrieve(string command);
    }
}
